apply_color_matrix_op (const Program *program,
const OpColorMatrix *op)
{
- float mat[16];
- OP_PRINT (" -> Color Matrix");
- graphene_matrix_to_float (op->matrix, mat);
- glUniformMatrix4fv (program->color_matrix.color_matrix_location, 1, GL_FALSE, mat);
+ OP_PRINT (" -> Color matrix. Send matrix: %d. Send offset: %d.",
+ op->matrix.send, op->offset.send);
+
+ if (op->matrix.send)
+ {
+ float mat[16];
+ graphene_matrix_to_float (op->matrix.value, mat);
+ glUniformMatrix4fv (program->color_matrix.color_matrix_location, 1, GL_FALSE, mat);
+ }
if (op->offset.send)
{
const graphene_vec4_t *offset)
{
ProgramState *current_program_state = get_current_program_state (builder);
+ const bool offset_equal = graphene_vec4_equal (offset, ¤t_program_state->color_matrix.offset);
+ const bool matrix_equal = graphene_matrix_equal_fast (matrix,
+ ¤t_program_state->color_matrix.matrix);
OpColorMatrix *op;
- bool offset_equal;
- offset_equal = memcmp (offset,
- ¤t_program_state->color_matrix.offset,
- sizeof (graphene_vec4_t)) == 0;
-
- if (memcmp (matrix,
- ¤t_program_state->color_matrix.matrix,
- sizeof (graphene_matrix_t)) == 0 &&
- offset_equal)
+ if (offset_equal && matrix_equal)
return;
- current_program_state->color_matrix.matrix = *matrix;
-
op = ops_begin (builder, OP_CHANGE_COLOR_MATRIX);
- op->matrix = matrix;
+
+ if (!matrix_equal)
+ {
+ current_program_state->color_matrix.matrix = *matrix;
+ op->matrix.value = matrix;
+ op->matrix.send = TRUE;
+ }
+ else
+ op->matrix.send = FALSE;
if (!offset_equal)
{
+ current_program_state->color_matrix.offset = *offset;
op->offset.value = offset;
op->offset.send = TRUE;
-
- current_program_state->color_matrix.offset = *offset;
}
else
op->offset.send = FALSE;
typedef struct { const GdkRGBA *value; guint send: 1; } RGBAUniformValue;
typedef struct { const graphene_vec4_t *value; guint send: 1; } Vec4UniformValue;
typedef struct { const GskColorStop *value; guint send: 1; } ColorStopUniformValue;
+typedef struct { const graphene_matrix_t *value; guint send: 1; } MatrixUniformValue;
/* OpNode are allocated within OpBuffer.pos, but we keep
* a secondary index into the locations of that buffer
typedef struct
{
- const graphene_matrix_t *matrix;
+ MatrixUniformValue matrix;
Vec4UniformValue offset;
} OpColorMatrix;